﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cinch;
using System.ComponentModel;
using System.ComponentModel.Composition;

namespace Anata.Client
{
    /// <summary>
    /// Represents a single Image ViewModel
    /// </summary>
    public class TransaksiLayananThumbnailViewModel : ViewModelBase
    {
        #region Data

        //private ViewMode currentViewMode = ViewMode.AddMode;

        #region Data.Primitives
        private Int32 idTransaksiLayanan;
        private Int32? idTransaksi;
        private Int32? idLayanan;
        private String namaLayanan;
        private Int32 hargaLayanan;
        private Int32? idKaryawan;
        private String namaKaryawan;
        private Int32 komisiKaryawan;
        private String namaPromo;
        private Int32 potonganPromo;
        private Int32 nilaiKepuasan;
        private String namaFreeGift;
        private Int32? idJenisStok;
        private String namaJenisStok;
        private Int32 jumlahFreeGift;
        private DateTime? waktuBuat;
        private DateTime? waktuTunggu;
        private DateTime? waktuMulai;
        private DateTime? waktuSelesai;
        private Boolean isBatal = false;

        

        //joined data
        private Int32? idKonsumen;
        private String namaKonsumen;

        private int previousStatusTransaksiLayanan;
        #endregion

        #region Data.Rules
        #endregion

        #region Data.VMs
        #endregion

        #region Data.Services
        #endregion

        #endregion

        #region Constructor
        public TransaksiLayananThumbnailViewModel()
        {
            #region Constructor.SetupServices
            #endregion

            #region Constructor.SetupCommands
            #endregion

            #region Constructor.CreateDataWrappers
            #endregion

            //fetch list of all DataWrappers, so they can be used again later without the
            //need for reflection
            //cachedListOfDataWrappers =
            //    DataWrapperHelper.GetWrapperProperties<TransaksiLayananThumbnailViewModel>(this);

            #region Create Validation Rules
            #endregion

            #region Constructor.SetupCollections
            #endregion
        }
        #endregion

        #region Static
        #endregion

        #region Public Properties

        #region Public.Commands
        #endregion

        #region Public.ViewMode
        #endregion

        #region Public.Data
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs idTransaksiLayananChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.IdTransaksiLayanan);
        public Int32 IdTransaksiLayanan
        {
            get { return idTransaksiLayanan; }
            set
            {
                idTransaksiLayanan = value;
                NotifyPropertyChanged(idTransaksiLayananChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs idTransaksiChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.IdTransaksi);
        public Int32? IdTransaksi
        {
            get { return idTransaksi; }
            set
            {
                idTransaksi = value;
                NotifyPropertyChanged(idTransaksiChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs idLayananChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.IdLayanan);
        public Int32? IdLayanan
        {
            get { return idLayanan; }
            set
            {
                idLayanan = value;
                NotifyPropertyChanged(idLayananChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs namaLayananChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.NamaLayanan);
        public String NamaLayanan
        {
            get { return namaLayanan; }
            set
            {
                namaLayanan = value;
                NotifyPropertyChanged(namaLayananChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs hargaLayananChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.HargaLayanan);
        public Int32 HargaLayanan
        {
            get { return hargaLayanan; }
            set
            {
                hargaLayanan = value;
                NotifyPropertyChanged(hargaLayananChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs idKaryawanChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.IdKaryawan);
        public Int32? IdKaryawan
        {
            get { return idKaryawan; }
            set
            {
                idKaryawan = value;
                NotifyPropertyChanged(idKaryawanChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs namaKaryawanChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.NamaKaryawan);
        public String NamaKaryawan
        {
            get { return namaKaryawan; }
            set
            {
                namaKaryawan = value;
                NotifyPropertyChanged(namaKaryawanChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs komisiKaryawanChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.KomisiKaryawan);
        public Int32 KomisiKaryawan
        {
            get { return komisiKaryawan; }
            set
            {
                komisiKaryawan = value;
                NotifyPropertyChanged(komisiKaryawanChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs namaPromoChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.NamaPromo);
        public String NamaPromo
        {
            get { return namaPromo; }
            set
            {
                namaPromo = value;
                NotifyPropertyChanged(namaPromoChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs potonganPromoChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.PotonganPromo);
        public Int32 PotonganPromo
        {
            get { return potonganPromo; }
            set
            {
                potonganPromo = value;
                NotifyPropertyChanged(potonganPromoChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs nilaiKepuasanChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.NilaiKepuasan);
        public Int32 NilaiKepuasan
        {
            get { return nilaiKepuasan; }
            set
            {
                nilaiKepuasan = value;
                NotifyPropertyChanged(nilaiKepuasanChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs namaFreeGiftChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.NamaFreeGift);
        public String NamaFreeGift
        {
            get { return namaFreeGift; }
            set
            {
                namaFreeGift = value;
                NotifyPropertyChanged(namaFreeGiftChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs idJenisStokChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.IdJenisStok);
        public Int32? IdJenisStok
        {
            get { return idJenisStok; }
            set
            {
                idJenisStok = value;
                NotifyPropertyChanged(idJenisStokChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs namaJenisStokChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.NamaJenisStok);
        public String NamaJenisStok
        {
            get { return namaJenisStok; }
            set
            {
                namaJenisStok = value;
                NotifyPropertyChanged(namaJenisStokChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs jumlahFreeGiftChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.JumlahFreeGift);
        public Int32 JumlahFreeGift
        {
            get { return jumlahFreeGift; }
            set
            {
                jumlahFreeGift = value;
                NotifyPropertyChanged(jumlahFreeGiftChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs waktuBuatChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.WaktuBuat);
        public DateTime? WaktuBuat
        {
            get { return waktuBuat; }
            set
            {
                waktuBuat = value;
                NotifyPropertyChanged(waktuBuatChangeArgs);
                NotifyPropertyChanged(statusTransaksiLayananChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs waktuTungguChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.WaktuTunggu);
        public DateTime? WaktuTunggu
        {
            get { return waktuTunggu; }
            set
            {
                waktuTunggu = value;
                NotifyPropertyChanged(waktuTungguChangeArgs);
                NotifyPropertyChanged(statusTransaksiLayananChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs waktuMulaiChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.WaktuMulai);
        public DateTime? WaktuMulai
        {
            get { return waktuMulai; }
            set
            {
                waktuMulai = value;
                NotifyPropertyChanged(waktuMulaiChangeArgs);
                NotifyPropertyChanged(statusTransaksiLayananChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs waktuSelesaiChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.WaktuSelesai);
        public DateTime? WaktuSelesai
        {
            get { return waktuSelesai; }
            set
            {
                waktuSelesai = value;
                NotifyPropertyChanged(waktuSelesaiChangeArgs);
                NotifyPropertyChanged(statusTransaksiLayananChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs isBatalChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.IsBatal);
        public Boolean IsBatal
        {
            get { return isBatal; }
            set
            {
                isBatal = value;
                NotifyPropertyChanged(isBatalChangeArgs);
                NotifyPropertyChanged(statusTransaksiLayananChangeArgs);
            }
        }
        
        
        
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs idKonsumenChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.IdKonsumen);
        public Int32? IdKonsumen
        {
            get { return idKonsumen; }
            set
            {
                idKonsumen = value;
                NotifyPropertyChanged(idKonsumenChangeArgs );
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs namaKonsumenChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.NamaKonsumen);
        public String NamaKonsumen
        {
            get { return namaKonsumen; }
            set
            {
                namaKonsumen = value;
                NotifyPropertyChanged(namaKonsumenChangeArgs);
            }
        }

        /// <summary>
        /// </summary>
        public int PreviousStatusTransaksiLayanan
        {
            get { return previousStatusTransaksiLayanan; }
            set
            {
                previousStatusTransaksiLayanan = value;
            }
        }
        #endregion

        #region Public.Cached Collection
        #endregion

        #region Public.DataVM
        #endregion

        #region Public.SummaryData
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs totalHargaLayananChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.TotalHargaLayanan);
        public Int32 TotalHargaLayanan
        {
            get
            {
                return HargaLayanan - PotonganPromo;
            }
        }

        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs statusTransaksiLayananChangeArgs =
            ObservableHelper.CreateArgs<TransaksiLayananThumbnailViewModel>(x => x.StatusTransaksiLayanan);
        public int StatusTransaksiLayanan
        {
            get
            {
                int retval = 0;
                if (isBatal)
                {
                    retval = 99;
                }
                else if (waktuBuat == null)
                {
                    retval = 0;
                }
                else if (waktuTunggu == null)
                {
                    retval = 1;
                }
                else if (waktuMulai == null)
                {
                    retval = 2;
                }
                else if (waktuSelesai == null)
                {
                    retval = 3;
                }
                else
                {
                    retval = 4;
                }
                return retval;
            }
        }
        #endregion

        #endregion

        #region Command Handlers
        #endregion

        #region Change Callbacks
        #endregion

        #region Private Methods
        #endregion

        #region Overrides
        public override string ToString()
        {
            return String.Format("TransaksiLayananThumbnailViewModel {0}", this.idTransaksiLayanan);
        }
        #endregion

        #region EditableValidatingViewModelBase overrides
        #endregion
    }
}
